home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2277 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: comma.rhein.de!yaps!arno
  2. From: arno@yaps.rhein.de (Arno Eigenwillig)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Setting DICE 3's variables to MEMF_PUBLIC
  5. Message-ID: <pKc0y*qzf@yaps.rhein.de>
  6. Date: Mon, 29 Jan 1996 17:57:45 +0100
  7. References: <4egfql$1lq@milo.freenet.vancouver.bc.ca>
  8. Organization: Yet Another Private Site in Meckenheim, Germany
  9. X-Copyright: This article may not be distributed on a CD-ROM
  10.  or in printed form without prior written consent of the author.
  11.  
  12. In article <4egfql$1lq@milo.freenet.vancouver.bc.ca>, Gordon Fecyk writes:
  13.  
  14. > I use MEMF_PUBLIC for all my 
  15. > AlocVec() and AllocMem() because all this data WILL get accessed 
  16. > externally (mainly freshly drawn fonts, etc) but I have no control over 
  17. > the memory the DICE startup code allocates, or the memory it sets aside 
  18. > for its local variables.
  19.  
  20. (Disclaimer: I am only familiar with V2 DICE, but the general problems
  21. should be the same.)
  22.  
  23. Unless your program is compiled to be pure (can be made resident), the
  24. start-up code does not allocate memory. It does not allocate memory
  25. for static const variables even for pure programs. (What use is there
  26. in making a patch program resident anyway?)
  27.  
  28. Non-__chip memory allocated by the OS at load time will be MEMF_PUBLIC
  29. (cf. Guru Book 22.2.1). (I am not sure about __chip-memory; maybe,
  30. maybe not, maybe Ralph is willing to clarify the issue.) This affects
  31. all static variables not dealt with in the previous paragraph.
  32.  
  33. Automatic variables are "allocated" on the stack. That is, automatic
  34. variables of your patch code are placed on the stack of the task
  35. calling the patched function. This makes the question whether your
  36. stack is MEMF_PUBLIC irrelevant. But switch off all fancy stack-
  37. related features like dynamic stack extension!
  38.  
  39. Only if you make a pointer to an automatic variable of a function
  40. running within your task's context visible to the patch code should
  41. the question whether your own stack is MEMF_PUBLIC be an issue. I am
  42. not sure. However, C= warns against using the stack for public data
  43. structures (cf. RKM I&A, p.6). But then, even existing C= example
  44. code does not take this too serious.
  45.  
  46. -- __
  47. __/// Arno Eigenwillig /\ <arno@yaps.rhein.de> \/ PGP key available.
  48. \XX/   V+49-2225-5870  /\ <Arnooo @ #amigager> \/ MIME 8bit welcome.
  49.